<?php
class DynamicCheckExistMaterialWarehouseInboundTokenAction extends CAction {
	public function run($token,$currentId) {
		$criteria=new CDbCriteria();
		$criteria->compare('token', $token);
		if($currentId){
			$criteria->compare('id', '<>'.$currentId);
		}
		$existItems=MaterialWarehouseInbound::model()->findAll($criteria);
		if(empty($existItems)){
			if($currentId){
				echo '恭喜你！编号为 '.$token.' 的入库单仅此一条';
			}else{
				echo '恭喜你！编号为 '.$token.' 的入库单尚未录入系统';
			}
		}else{
			echo '编号为'.$token.'的入库单已经有了哦，'.CHtml::link('点击这里看看是咋回事',array('index',
				'MaterialWarehouseInboundSearch'=>array(
					'token'=>$token
				)
			),array(
				'target'=>'_blank'
			));
		}
	}
}